package com.neo.impatient.C12_function.C12_06_closure

class MulByTest {

}

object MulByTest{

  /**
    * 每一个返回的函数都有自己的factor设置，这样的一个函数称为闭包
    * @param factor
    * @return
    */
  def mulBy(factor: Double) = (x:Double) => factor * x


  def main(args: Array[String]): Unit = {
    val triple = mulBy(3)
    val half = mulBy(4)
    println(triple(2))
    println(half(4))
  }



}
